$(document).ready(function () {
    initFunction();
})

/*function deleteArticle(id) {
    $.ajax({
        url:"/api/deletearticle/"+id,
        type:"Delete",
        dataType:"json",
        success:function(data){
            initArticle();
            layer.msg(data.message,{icon: 5});
        },
        error:function () {
            layer.msg("系统错误！",{icon: 5});
        }
    });
}*/

function initFunction() {
    $.ajax({
        type: 'get',
        url: '/api/role',
        dataType:"json",
        data:{
          "pageSize":20,
          "pageNumber":0
        },
        success: function (result) {
            var data = result.data;
            $("#role_list").html("")
            var val = "";
            data.forEach(function(value,index){

                val = val+ "<tr><td>"+value.rid +
                    "</td><td>"+value.name+"</td><td>"+value.code+"</td><td>"+value.description+"</td><td>" +
                    "<a role=\"button\" href=\"/api/setfunction/"+value.rid+"\" class=\"btn_edit\"  style=\"border: 1px solid #F37B1D;padding: 2px 4px;margin: 0px 4px;\">" +
                    "<span class='glyphicon glyphicon-file'></span>编辑权限</a>" +
                    "<a role=\"button\" class=\"btn_delete\" onclick='deleteArticle("+value.rid+")' style=\"border: 1px solid #e7505a;padding: 2px 4px;margin: 0px 4px;\">" +
                    "<span class='glyphicon glyphicon-trash'></span>删除</a></td></tr>";
            });
            $("#role_list").append(val)
        },
        error:function () {
            layer.msg("系统错误！",{icon: 5});
        }
    });
}

